<template>
  <div class="material-goods">
    <div
      :class="['material-goods-list', `material-goods-list-active-` + amount]"
      v-for="(item, index) in list"
      :key="index"
    >
      <div class="material-goods-list-header">
        <div class="material-header-img">
          <!-- <img class="image-100" :src="item.pic" alt="" /> -->
          <el-image fit="fill" :src="item.pic" lazy></el-image>
        </div>
        <div class="material-header-icon">
          <img
            v-if="item.is_collect == 0"
            class="image-100"
            src="@/assets/icon/cancel-collection.png"
            alt=""
          />
          <img
            v-else
            class="image-100"
            src="@/assets/icon/collection.png"
            alt=""
          />
        </div>
      </div>
      <div class="material-goods-list-title">
        <div class="material-title-look">查看详情</div>
      </div>
      <div class="material-goods-show">
        <div class="material-show" @click="onMaterialInfo(item)">
          <div class="material-show-name">
            <div class="material-show-name-type">尺寸/规格：</div>
            <div class="material-show-name-amount using-single-drug">
              {{ item.spec }}
            </div>
          </div>
          <div class="material-show-name">
            <div class="material-show-name-type">大小：</div>
            <div class="material-show-name-amount using-single-drug">
              {{ item.size }}
            </div>
          </div>
          <div class="material-show-name">
            <div class="material-show-name-type">适合工艺：</div>
            <div class="material-show-name-amount using-single-drug">
              {{ item.craft }}
            </div>
          </div>
          <div class="material-show-name">
            <div class="material-show-name-type">合适设计区域：</div>
            <div class="material-show-name-amount using-single-drug">
              {{ item.design_area }}
            </div>
          </div>
          <div class="material-show-name">
            <div class="material-show-name-type">适合品类：</div>
            <div class="material-show-name-amount using-single-drug">
              {{ item.fit_cate }}
            </div>
          </div>
          <div class="material-show-info">
            <div class="material-show-info-btn">查看详情</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapMutations } from 'vuex';
export default {
  name: 'materialGoods',
  components: {},
  props: {
    amount: {
      type: String,
      default: '5',
    },
    list: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  data() {
    return {};
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    ...mapMutations(['getTabMall']),
    // 跳转到素材详情
    onMaterialInfo(item) {
      // this.getTabMall('materialInfo');
      this.$router.push({ name: 'materialInfo', query: { id: item.id } });
      // localStorage.setItem('toolValueIndex', 'materialInfo');
    },
  },
  mounted() {},
};
</script>

<style scoped lang="less">
.material-goods {
  display: flex;
  flex-wrap: wrap;

  .material-goods-list {
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid #ebebeb;
    border-radius: 4px;
    overflow: hidden;
    margin: 0 24px 14px 0;
    width: 180px;

    .material-goods-list-header {
      position: relative;
      width: 100%;
      height: 188px;

      .material-header-img {
        width: 100%;
        height: 100%;

        /deep/ .el-image {
          width: 100%;
          height: 100%;
        }
      }

      .material-header-icon {
        position: absolute;
        right: 10px;
        top: 10px;
        cursor: pointer;
        width: 24px;
        height: 24px;
      }
    }
    .material-goods-list-title {
      display: flex;
      flex-direction: column;
      justify-content: space-evenly;
      align-items: center;
      padding: 0 14px;
      height: 44px;

      .material-title-look {
        cursor: pointer;
        font-size: 16px;
        color: #00091a;
      }
    }

    &:hover .material-goods-show {
      display: block;

      .material-show {
        animation: showHeight 0.5s 1;
      }
    }
    // 底部展示框
    .material-goods-show {
      display: none;
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      cursor: pointer;
      height: 100%;
      border-radius: 4px;
      background-color: rgba(0, 0, 0, 0.5);

      .material-show {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 8px;
        height: 179px;
        background-color: #fff;

        .material-show-name {
          display: flex;

          .material-show-name-type {
            margin-bottom: 4px;
            font-size: 14px;
            color: #999999;
          }

          .material-show-name-amount {
            font-size: 14px;
            color: #00091a;
          }
        }

        .material-show-info {
          margin: 12px auto 0;
          width: 86px;
          text-align: center;
          height: 32px;
          line-height: 32px;
          background-color: #00359b;
          border-radius: 4px;

          .material-show-info-btn {
            font-size: 16px;
            color: #ffffff;
          }
        }
      }
    }
  }

  .material-goods-list-active-6:nth-child(6n) {
    margin: 0 0 14px 0;
  }
  .material-goods-list-active-5:nth-child(5n) {
    margin: 0 0 14px 0;
  }
}
// 展示高度动画
@keyframes showHeight {
  0% {
    height: 0;
  }
  100% {
    height: 179px;
  }
}
</style>
